package com.example.demo.service.impl;

import com.example.demo.dao.MeasureDao;
import com.example.demo.entity.Measure;
import com.example.demo.service.MeasureService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class MeasureServiceImpl implements MeasureService {
    @Resource
    private MeasureDao measureDao;

    @Override
    public List<Measure> getAllMeasureByDesId(String desId) {
        return measureDao.getAllMeasureByDesId(desId);
    }

    @Override
    public Measure getMeasureById(Integer id) {
        return measureDao.getMeasureById(id);
    }

    @Override
    public Integer modifyMeasureById(Measure measure) {
        return measureDao.modifyMeasureById(measure);
    }

    @Override
    public Integer measureAdd(Measure measure) {
        measure.setMeasureTime(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
        return measureDao.measureAdd(measure);
    }

    @Override
    public Integer count(String desId) {
        return measureDao.count(desId);
    }

    @Override
    public List<Measure> getMeasure(String keyword,String desId) {
        return measureDao.getMeasure(keyword,desId);
    }
}
